home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.arch.arithmetic,comp.lang.c,comp.lang.c++
- Subject: Re: Access carry flag from C
- Date: 20 Feb 1996 17:11:10 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb20101110@qcd.lanl.gov>
- References: <Dn1C9z.DGv.0.net@indra.com> <1996Feb1922.17.19.879@koobera.math.uic.edu>
- <31298D20.41C6@bazis.nl> <ARTHUR.96Feb20143404@gold.Smallworld.co.uk>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: arthur@Smallworld.co.uk's message of 20 Feb 1996 14:34:03 GMT
-
- In article <ARTHUR.96Feb20143404@gold.Smallworld.co.uk>
- arthur@Smallworld.co.uk (Arthur Chance) writes:
- <snip>
- In article <31298D20.41C6@bazis.nl> Franz Korntner <fkorntne@bazis.nl> writes:
- > j+k will overflow when the result exceeds MAXINT
- >
- > Thus: "if (j+k > MAXINT) overflow();" but the operation is undefined
- > if the result overflows, so the expression needs rewriting to make sure
- > this doesn't happen. The result is then "if (j>MAXINT-k) overflow();".
-
- As we must be talking about signed ints, because unsigned can't cause
- undefined behaviour by overflow, if k < 0, then MAXINT-k overflows.
-
- Basically, the C *standard* is useless on things like signed overflow
- (or word size, or what happens with right shift of -ve numbers, or
- <insert your favourite "undefined behaviour" gripe here>). You have
- to look carefully at each *implementation* you use. You can usually
-
- Actually you are mixing up the concepts of `undefined behaviour' and
- `implementation-defined behaviour'. In the case of the former, even
- looking at the implementation documentation need not be sufficient: in
- the latter, the documentation has to tell you what happens.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-